package leetcode.code0965;

import leetcode.IDebug;
import leetcode.helper.tree.TreeNode;

public class Solution implements IDebug {
	public boolean isUnivalTree(TreeNode root) {
		return this.isUnivalTree(root, root.val);
	}

	private boolean isUnivalTree(TreeNode root, int val) {
		if (root == null) {
			return true;
		}
		if (root.val != val) {
			return false;
		}
		if (!this.isUnivalTree(root.left, val)) {
			return false;
		}
		if (!this.isUnivalTree(root.right, val)) {
			return false;
		}
		return true;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
